#include "list.h"
ListNode* deleteDuplicates(ListNode* head) {
  if (!head) {
    return head;
  }

  ListNode* dummy = new ListNode(0, head);

  ListNode* cur = dummy;
  while (cur->next_ && cur->next_->next_) {
    if (cur->next_->data_ == cur->next_->next_->data_) {
      int x = cur->next_->data_;
      while (cur->next_ && cur->next_->data_ == x) {
        cur->next_ = cur->next_->next_;
      }
    } else {
      cur = cur->next_;
    }
  }

  return dummy->next_;
}